package cc.minos.xmpp.seesmic
{
	import cc.minos.xmpp.interfaces.IServer;
	import com.seesmic.as3.xmpp.StreamEvent;
	import com.seesmic.as3.xmpp.xep.muc.MUC;
	import com.seesmic.as3.xmpp.xep.publish_subscribe.PublishSubscribe;
	import com.seesmic.as3.xmpp.xep.publish_subscribe.PubSubEvent;
	import com.seesmic.as3.xmpp.XMPP;
	import com.seesmic.as3.xmpp.XMPPEvent;
	
	/**
	 * ...
	 * @author Minos
	 */
	public class Seesmic implements IServer
	{
		
		public var conn:XMPP;
		
		public function Seesmic()
		{
			conn = new XMPP();
			conn.addEventListener( XMPPEvent.MESSAGE , onMessage );
			conn.addEventListener( XMPPEvent.MESSAGE_MUC , onMUCMessage );
			conn.addEventListener( XMPPEvent.SESSION , onSession );
			conn.addEventListener( XMPPEvent.SECURE , onSecure );
			conn.addEventListener( XMPPEvent.AUTH_SUCCEEDED , onAuthSucceed );
			conn.addEventListener( XMPPEvent.AUTH_FAILED , onAuthFailed );
			conn.addEventListener( XMPPEvent.PRESENCE_AVAILABLE , onPresence );
			conn.addEventListener( XMPPEvent.PRESENCE_UNAVAILABLE , onPresenceUnAvail );
			conn.addEventListener( XMPPEvent.PRESENCE_ERROR , onPresenceError );
			conn.addEventListener( XMPPEvent.PRESENCE_SUBSCRIBE , onPresenceSubscribe );
			conn.addEventListener( XMPPEvent.ROSTER_ITEM , onRoster );
			conn.socket.addEventListener( StreamEvent.DISCONNECTED , onDisconnected );
			conn.socket.addEventListener( StreamEvent.CONNECT_FAILED , onConnectFailed );
			conn.socket.addEventListener( StreamEvent.CONNECTED , onConnected );
			
			conn.addPlugin( new PublishSubscribe() );
			conn.addPlugin( new MUC() );
		
			//conn.plugin[ 'pubsub' ].addEventListener( PubSubEvent.ITEM , handlePubSubItem );
			//conn.plugin[ 'pubsub' ].addEventListener( PubSubEvent.RETRACT , handlePubSubRetract );
		
			//conn.setupTLS(TLSEvent, TLSConfig, TLSEngine, TLSSocket, true, true, false);
		
			//conn.connect();
		}
		
		/* INTERFACE cc.minos.xmpp.interfaces.IServer */
		
		public function login( conf:* ):void
		{
			
			conn.setJID( jid );
			conn.setPassword( psw );
			conn.setServer( svr );
			conn.connect();
		}
		
		public function logout():void
		{
			conn.disconnect();
		}
		
		public function send( msg:* ):void
		{
			//
		}
		
		/* event handlers */
		
		private function onMessage( e:XMPPEvent ):void
		{
		
		}
		
		private function onMUCMessage( e:XMPPEvent ):void
		{
		
		}
		
		private function onSession( e:XMPPEvent ):void
		{
		
		}
		
		private function onSecure( e:XMPPEvent ):void
		{
		
		}
		
		private function onAuthSucceed( e:XMPPEvent ):void
		{
		
		}
		
		private function onAuthFailed( e:XMPPEvent ):void
		{
		
		}
		
		private function onPresence( e:XMPPEvent ):void
		{
		
		}
		
		private function onPresenceUnAvail( e:XMPPEvent ):void
		{
		
		}
		
		private function onPresenceError( e:XMPPEvent ):void
		{
		
		}
		
		private function onPresenceSubscribe( e:XMPPEvent ):void
		{
		
		}
		
		private function onRoster( e:XMPPEvent ):void
		{
		
		}
		
		private function onDisconnected( e:StreamEvent ):void
		{
		
		}
		
		private function onConnectFailed( e:StreamEvent ):void
		{
		
		}
		
		private function onConnected( e:StreamEvent ):void
		{
		
		}
	
	}

}